﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Result.aspx.cs" Inherits="Web.Views.Home.Result" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta name="screen-orientation" content="portrait">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
    <title>抽奖小程序</title>
    <link rel="stylesheet" type="text/css" href="../../Content/assets/css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../Content/assets/css/wall.css">
    <style type="text/css">
        .wall {
            overflow: scroll;
            background-repeat: repeat;
        }

        ::-webkit-scrollbar {
            display: none;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        .mask {
            -webkit-filter: blur(5px);
            filter: blur(5px);
        }

        #main {
            -webkit-transition: all 1s;
            transition: all 1s;
        }

        .result-list {
            text-align: center;
            color: #4de7c8;
            font-size: 30px;
            line-height: 50px;
            margin-top: 50px;
            margin-bottom: 50px;
            font-family: '幼圆';
        }

        .result-title {
            text-align: center;
            color: #4de7c8;
            font-size: 40px;
            margin-top: 100px;
            font-family: '幼圆';
        }
    </style>
</head>
<body>
    <div id="main" class="wall">
        <div class="result-title">获奖名单</div>
        <div class="result-list" v-for="result in results">
            <div v-for="item in result">
                <p v-html="item"></p>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../Content/assets/js/vue.js"></script>
    <script type="text/javascript">
    new Vue({
        el: '#main',
        data: {
            results: []
        },
        mounted () {
            let vm = this
            let locals = window.localStorage
            let str_results = []

            // 遍历(排除choosed)
            for(let i = 0; i<localStorage.length; i++){
                if (localStorage.key(i) !== 'choosed') {
                    //console.log(localStorage.key(i));
                    str_results.push(localStorage.getItem(localStorage.key(i)))
                }
            }
            console.log(str_results);
            let choosed = localStorage.getItem('choosed');//获奖名单
            let chary = choosed.split(',');//选中数组倒序
            //chary = chary.reverse();
            console.log(chary);

            // 分割每个string, 并将</br>换成空格
            let results = []
            for (let i = 0; i < chary.length; i++) {
                console.log(chary[i]);
                let temp = JSON.parse(localStorage.getItem(i + 1))
                results.push(temp);
            }
            //for(let nameList of str_results) {
            //    let temp = JSON.parse(nameList)
            //    //temp = temp.map(item => {return item.replace('<br/>', ' ')})
            //    //temp = temp.map(item)
            //    results.push(temp)
            //}
            console.log(results);
            // 根据长度进行排序，名单短的放在前面
            //results = results.sort((x, y) => { return x.length - y.length;})
            this.results = results.reverse();
        },
    })
    </script>
</body>
</html>
